package com.eascs.workflow.org.service.impl;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.eascs.workflow.org.dao.OrganDao;
import com.eascs.workflow.org.entity.Organ;
import com.eascs.workflow.org.service.OrganService;

@Service
public class OrganServiceImpl implements OrganService {
	@Autowired
	private OrganDao organDao;

	@Override
	public List<Organ> getOrganTreeByUnitNo(String unitNo) {
		List<Organ> orgList = new ArrayList<Organ>();
		// 先根据UnitNo 找出自己的组织ID
		Organ organ = organDao.getOrgByUnitNo(unitNo);
		orgList.add(organ);

		while (!organ.getParentId().equals("-1")) {
			organ = organDao.getOrgByOrgId(organ.getParentId());
			orgList.add(organ);
		}

		return orgList;
	}

}
